import java.io.*;
import java.net.*;

/**
 * TCPClient.java, Not in use in TCPServer anymore.
 * @author Xiaohui Li
 *
 */
class TCPClient {
	public static void main(String argv[]) throws Exception {
		// String FromServer;
		String ToServer;
		String serverIP = "localhost";
		int portnumber = 5301;

		Socket clientSocket = new Socket(serverIP, portnumber);
		BufferedReader inFromUser = new BufferedReader(new InputStreamReader(
				System.in));

		PrintWriter outToServer = new PrintWriter(clientSocket
				.getOutputStream(), true);

		while (true) {

			System.out.println("SEND STH(Type Q or q to Quit):");
			ToServer = inFromUser.readLine();

			if (ToServer.equals("Q") || ToServer.equals("q")) {
				outToServer.println(ToServer);
				clientSocket.close();
				break;
			}

			else {
				outToServer.println(ToServer);
			}
			// }
		}
	}
}